package com.tupi.project.base;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tupi.project.R;

import java.util.List;

/**
 * BaseRecyclerViewAdapter
 * Created by CPP on 2017/12/10.
 */

public abstract class BaseRecyclerViewAdapter<T, K extends BaseViewHolder> extends
        BaseQuickAdapter<T, K>
{
    
    public BaseRecyclerViewAdapter(@LayoutRes int layoutResId, @Nullable List data)
    {
        super(layoutResId, data);
    }
    
    public BaseRecyclerViewAdapter(@Nullable List data)
    {
        super(data);
    }
    
    public BaseRecyclerViewAdapter(@LayoutRes int layoutResId)
    {
        super(layoutResId);
    }
    
    public BaseRecyclerViewAdapter setDefaultAdapter(RecyclerView recyclerView,
                                                     BaseQuickAdapter.RequestLoadMoreListener
                                                             requestLoadMoreListener)
    {
        //切换动画
        openLoadAnimation(BaseQuickAdapter.ALPHAIN);
        //动画默认只执行一次,如果想重复执行可设置
        isFirstOnly(false);
        //设置不显示动画数量
        setNotDoAnimationCount(10);
        setOnLoadMoreListener(requestLoadMoreListener, recyclerView);
        setEmptyView(R.layout.empty_layout);
        TextView emptyTv = (TextView) getEmptyView().findViewById(R.id.empty_tv);
        emptyTv.setText("暂无数据");
        return this;
    }
    
    
}
